package com.wzdigit.wms.basic.enums;

import java.util.*;

/**
 * 二维码解析Goods
 */
public enum QrCodeGoodsEnum implements BaseEnum {

	SKU_CODE("MaterialCode", "skuCode", "物料编码"),
	QTY("Qty", "qty", "数量"),
	VENDOR_CODE("VendorCode", "VendorCode", "供应商编码"),
	DATECODE("DateCode", "datecode", "datecode"),
	GROSS_WEIGHT("GrossWeight", "grossWeight", "毛重"),
	NET_WEIGHT("NetWeight", "netWeight", "净重"),
	LWH("LWH", "lwh", "长宽高"),
	PRD_LOT("ProductionBatch", "prdLot", "生产批次"),
	VEN_LOTNO("VendorLotno", "venLotno", "供方批次"),
	GOODS_SN("PKGShortSN", "goodsSn", "条码SN"),
	CUSTOM("Custom", "custom", "自定义");

    /**
     * 枚举值
     */
    public String code;

    /**
     * 枚举名称
     */
    public String enumName;

    /**
     * 枚举实体类属性描述
     */
    public String description;

    QrCodeGoodsEnum(String enumName, String description) {
        this.enumName = enumName;
        this.description = description;
    }

    QrCodeGoodsEnum(String code, String enumName, String description) {
        this.code = code;
        this.enumName = enumName;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
    public String getEnumName() {
        return enumName;
    }

    public void setEnumName(String enumName) {
        this.enumName = enumName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public static QrCodeGoodsEnum getEnumByCode(String enumCode) {
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        QrCodeGoodsEnum samplingEnum = null;

        for (QrCodeGoodsEnum value : values) {
            if (Objects.equals(value.getCode(), enumCode)) {
                samplingEnum = value;
                break;
            }
        }
        return samplingEnum;
    }

    public static QrCodeGoodsEnum getEnumByName(String enumName) {
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        QrCodeGoodsEnum repairEnum = null;

        for (QrCodeGoodsEnum value : values) {
            if (Objects.equals(value.getEnumName(), enumName)) {
                repairEnum = value;
            }
        }
        return repairEnum;
    }

    public static String getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        for (QrCodeGoodsEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)
                    && Objects.equals(value.getEnumName(), enumName)) {
                return value.getCode();
            }
        }
        return null;
    }

    public static Map<String, String> getEnumByDescription() {
        Map<String, String> enumMap = new HashMap<String, String>();
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        for (QrCodeGoodsEnum value : values) {
        	enumMap.put(value.getCode(), value.getEnumName());
        }
        return enumMap;
    }
    
    public static Map<String, String> getEnumByDescription(String enumDescription) {
        Map<String, String> enumMap = new HashMap<String, String>();
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        for (QrCodeGoodsEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                enumMap.put(value.getCode(), value.getEnumName());
            }
        }
        return enumMap;
    }

    public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        QrCodeGoodsEnum[] values = QrCodeGoodsEnum.values();
        for (QrCodeGoodsEnum value : values) {
            if (Objects.equals(value.getDescription(), enumDescription)) {
                Map<String, Object> enumMap = new HashMap<String, Object>(2);
                enumMap.put("code", value.getCode());
                enumMap.put("name", value.getEnumName());
                list.add(enumMap);
            }
        }
        return list;
    }
}
